﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DAL;
using BLL;

public partial class Baiviet_Ketluan : System.Web.UI.UserControl
{
    HOSOBENHANBLL hsbaBll = new HOSOBENHANBLL();
    static HOSOBENHAN hsba = new HOSOBENHAN();
    BAIVIETBLL bvBll = new BAIVIETBLL();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            //set visibale for Khach
            VAITRO vt = (VAITRO)Session["vaitroObject"];
            if (vt.tenvaitro.Equals("Khách"))
            {
                edit_kl.Visible = false;
            }
            else
            {
                THANHVIEN checkTv = (THANHVIEN)Session["thanhvienObject"];
                THANHVIEN ttvietbai = bvBll.getThanhvienWithIDBaiviet(Int32.Parse(Page.Request["mabv"]));
                if (ttvietbai.mathanhvien != checkTv.mathanhvien)
                {
                    edit_kl.Visible = false;
                }
            }


            hsba = hsbaBll.getHosobenhanWithIdBaiviet(Int32.Parse(Page.Request["mabv"]));
            lb_kl.Text = hsba.ketluan;
        }
    }

    protected void edit_kl_Click(object sender, EventArgs e)
    {
        RadEditor1.Visible = true;
        ok_kl.Visible = true;
        edit_kl.Visible = false;
    }
    protected void ok_kl_Click(object sender, EventArgs e)
    {
        RadEditor1.Visible = false;
        ok_kl.Visible = false;
        edit_kl.Visible = true;
        lb_kl.Text = RadEditor1.Content;

        //update ketluan
        hsbaBll.updateKetluanWithIDBaiviet(Int32.Parse(Page.Request["mabv"]), RadEditor1.Content);

    }
}
